
public class StringCompare {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		String s1 = new String("hello");
		String s2 = "goodbye";
		String s3 = "Happy Birthday";
		String s4 = "happy birthday";
		
		
		System.out.printf("\ns1 = %s " +
				"\ns2 = %s" +
				"\ns3 = %s" +
				"\ns4 = %s", s1, s2, s3, s4);
		// test for equality
		
		if(s1.equals("hello")) {
			System.out.println("s1 eauals \"hello\"");
		}
		else {
			System.out.println("s1 not eauals \"hello\"");
		}
		
		// test for equality with ==
		
		if( s1 == "hello") {
			System.out.println("s1 is the same object like hello");
		}
		else {
			System.out.println("s1 is not the same object like hello");
		}
		
		// test compareto
		
		System.out.printf("\n s1 compare to(s2, args) is %d", s1.compareTo(s2));
		System.out.printf("\n s2 compare to(s1, args) is %d", s2.compareTo(s1));
		System.out.printf("\n s1 compare to(s1, args) is %d", s1.compareTo(s1));
		System.out.printf("\n s4 compare to(s4, args) is %d", s3.compareTo(s4));
		System.out.printf("\n s4 compare to(s3, args) is %d", s4.compareTo(s3));

	}

}
